﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Senbo.Model.Entities;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Infrastructure;

namespace Senbo.Model
{
    public class SenboDBContext : DbContext, IDisposable
    {
        private readonly static string CONNECTION_STRING = "name=SenboDBContext_ConnString";
        public DbSet<AdminUser> Admins { get; set; }
        public DbSet<Category> Categorys { get; set; }
        public DbSet<Picture> Pictures { get; set; }
        public SenboDBContext()
            : base(CONNECTION_STRING)
        {
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();//移除复数表名的契约
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();//防止黑幕交易 要不然每次都要访问 EdmMetadata这个表
            //modelBuilder.Entity<Movie>().Property(p =>p.Price).HasPrecision(18, 2);
        }
    }
}
